package com.fare.taluo.core.domain.queue.warn;

import java.util.List;

import com.fare.taluo.core.domain.analyse.alert.FreightPriceAnalyseAlertConfigEntity;
import com.fare.taluo.fetl.domain.entity.FreightMonitorCabinsEntity;
import com.fare.taluo.fetl.domain.entity.FreightMontiorEntity;
import com.fare.taluo.util.DateUtils;

public class CabinChangeWarnStrategy {
private FreightPriceAnalyseAlertConfigEntity config;
private List<FreightMontiorEntity> subList ;	
	public CabinChangeWarnStrategy(FreightPriceAnalyseAlertConfigEntity config,List<FreightMontiorEntity> subList){
		this.config = config;
		this.subList = subList;
	}
	
	
	
	public String buildEmailContent(){
		StringBuffer buffer = new StringBuffer();
		buffer.append(DateUtils.formatDay(config.getFlightDate(), "yyyy-MM-dd"));
		buffer.append("起飞的");
		buffer.append("<span style=\"color: #ff0000\">"+config.getFlightNo()+"</span>");
		buffer.append("出现舱位变化<br>");
		for (FreightMontiorEntity entity : subList) {
			buffer.append("抓取时间为"+DateUtils.formatDay(entity.getGrabDate(), "yyyy-MM-dd HH:mm")+"<span style=\"color: #ff0000\">"+entity.getGrabChannel()+"的"+entity.getFlightNo()+"</span>"+"的舱位如下:");
			for (FreightMonitorCabinsEntity cabinEntity : entity.getCabinList()) {
				if(cabinEntity.getCabinName()!=null){
					buffer.append(cabinEntity.getCabinName()+":"+cabinEntity.getPrice()+"  ");
				}else if(cabinEntity.getCabinType()!=null){
					buffer.append(cabinEntity.getCabinType()+":"+cabinEntity.getPrice()+"  ");
				}
				
			}
			buffer.append("<br>");
		}
		
		
		return buffer.toString();
	}
}
